home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Utilities / RemoteCommand / Source / execServer.subproj / ExecServer.h < prev    next >
Encoding:
Text File  |  1993-06-10  |  3.7 KB  |  101 lines

  1. // -------------------------------------------------------------------------------------
  2. //  ExecServer
  3. // -------------------------------------------------------------------------------------
  4. #import <objc/Object.h>
  5. #import <machkit/NXData.h>
  6.  
  7. // -------------------------------------------------------------------------------------
  8. // possible return errors (Note: these may be shared with the executed process)
  9. #define        RSRV_SUCCESS        0            // successful completion
  10. #define        RSRV_ABORTED        0xF001        // process aborted
  11. #define        RSRV_FORK            0xF002        // fork() failed
  12. #define        RSRV_UNKNOWN        0xF003        // unknown error
  13. #define        RSRV_BADPASSWD        0xF004        // Invalid user password
  14. #define        RSRV_BADUSER        0xF005        // Bad user name
  15. #define        RSRV_BADGID            0xF006        // setgid error
  16. #define        RSRV_BADUID            0xF007        // setuid error
  17. #define        RSRV_BADINIT        0xF008        // initgroups error
  18. #define        RSRV_EXEC            0xF009        // exec() failed
  19. #define        RSRV_UNDEF            0xF00A        // Undefined target
  20. #define        RSRV_RSH            0xF00B        // remote rsh exec() failed
  21.  
  22. // -------------------------------------------------------------------------------------
  23. // handle to ExecServer exec process
  24. #define        execHandle_t        u_int
  25.  
  26. // -------------------------------------------------------------------------------------
  27. @protocol RemoteClient        // sent by server to client
  28. - (oneway void)commandOutput:(const char*)buffer len:(int)length;
  29. - (oneway void)commandDidCompleteWithError:(int)errorCode;
  30. @end
  31. #define RemoteClient_PROTOCOL
  32.  
  33. // -------------------------------------------------------------------------------------
  34. @interface ExecServer : Object <NXSenderIsInvalid>
  35. { @public
  36.  
  37.     BOOL                isRunning;                            // true if server is running
  38.     
  39.     int                    rootChild;                            // process handle
  40.     id                    rootServer;                            // remote object id
  41.     
  42.     id                    methodDelegate;                        // class object id
  43.     
  44.     char                mainAppPath[MAXPATHLEN + 1];        // path to app wrapper
  45.     char                mainAppHost[MAXHOSTNAMELEN + 1];    // main app host
  46.     char                mainAppServerName[256];                // main app server name
  47.     char                remoteHost[MAXHOSTNAMELEN + 1];        // remote host name
  48.     char                remoteServerName[256];                // remote server name
  49.     char                serverCommandName[MAXPATHLEN + 1];    // remote server command
  50.  
  51.     BOOL                exitWhenDone;                        // exit when no clients
  52.     
  53. }
  54.  
  55. // -------------------------------------------------------------------------------------
  56.  
  57. /* initializing ExecServer */
  58. // These must be sent prior to 'startServer' in order for them to be effective.
  59. - setExitWhenDone:(BOOL)flag;
  60. - setMethodDelegate:classId;
  61. - setMainAppPath:(const char*)appPath;
  62. - setMainAppServerName:(const char*)servName host:(const char*)hostName;
  63. - setRemoteHost:(const char*)hostName;
  64. - setRemoteServerName:(const char*)serverName;
  65. - setServerCommandName:(const char*)cmdPath;
  66.  
  67. /* query ExecServer attributes */
  68. - (const char*)mainAppServerName;
  69. - (const char*)mainAppHost;
  70. - (const char*)remoteHost;
  71. - (const char*)remoteServerName;
  72.  
  73. /* ExecServer startup */
  74. - (void)_runServer;
  75. - startServer;
  76.  
  77. /* password check */
  78. - (BOOL)needUserPassword:(const char*)userName;
  79.  
  80. /* ExecServer shell script command service */
  81. - (BOOL)isRunningAsRoot;
  82. - (execHandle_t)runCommand:(const char*)cmd
  83.         withUser:(const char*)userName:(const char*)password
  84.         forClient:(id <RemoteClient>)client
  85.         killOnError:(BOOL)killOnError;
  86. - (execHandle_t)runCommand:(const char*)cmd
  87.         forClient:(id <RemoteClient>)client
  88.         killOnError:(BOOL)killOnError;
  89. - terminateCommand:(execHandle_t)runId;
  90. - killCommand:(execHandle_t)runId;
  91. - (BOOL)commandIsActive:(execHandle_t)runId;
  92. - shutDownServer;
  93.  
  94. /* ExecServer class method service (requires setMethodDelegate: set) */
  95. - (int)perform:(SEL)method withArg:(const char*)arg
  96.         withUser:(const char*)userName:(const char*)password;
  97.  
  98. /* return description to specified error code */
  99. + (char*)errorDesc:(int)err;
  100.  
  101. @end